package com.loctek.importexport.util;

import android.os.CountDownTimer;
import android.widget.TextView;

/**
 * Created by slf on 2018/1/30.
 */

public class MyCountDownTimer extends CountDownTimer {

    private TextView mTextView;

    public MyCountDownTimer(long millisInFuture, long countDownInterval, TextView textView) {
        super(millisInFuture, countDownInterval);
        mTextView = textView;
    }

    //计时过程
    @Override
    public void onTick(long l) {
        //防止计时过程中重复点击
        mTextView.setEnabled(false);
        mTextView.setText(l / 1000 + "秒后重新获取");

    }

    //计时完毕的方法
    @Override
    public void onFinish() {
        //重新给Button设置文字
        mTextView.setText("重新获取验证码");
        //设置可点击
        mTextView.setEnabled(true);
    }
}
